<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('访客信息列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list" style="white-space: nowrap">
                    <ul>
                        <!--                            <li>-->
                        <!--                                <p>微信返回用户的唯一标识：</p>-->
                        <!--                                <input type="text" name="openId"/>-->
                        <!--                            </li>-->
                        <li>
                            <p>姓名：</p>
                            <input type="text" name="name"/>
                        </li>
                        <li>
                            <p>性别：</p>
                            <!--                                <input type="text" name="gender"/>-->
                            <select name="gender" th:with="type=${@dict.getType('sys_user_sex')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.getDictLabel()}"
                                        th:value="${dict.getDictValue()}"></option>
                            </select>
                        </li>
                        <li>
                            <p>身份证号码：</p>
                            <input type="text" name="idNumber"/>
                        </li>
                        <li>
                            <p>手机号码：</p>
                            <input type="text" name="phone"/>
                        </li>
                        <!--                            <li>-->
                        <!--                                <p>现住址：</p>-->
                        <!--                                <input type="text" name="presentAddress"/>-->
                        <!--                            </li>-->
                        <!--                            <li>-->
                        <!--                                <p>省：</p>-->
                        <!--                                <input type="text" name="province"/>-->
                        <!--                            </li>-->
                        <!--                            <li>-->
                        <!--                                <p>市：</p>-->
                        <!--                                <input type="text" name="city"/>-->
                        <!--                            </li>-->
                        <!--                            <li>-->
                        <!--                                <p>区/县：</p>-->
                        <!--                                <input type="text" name="district"/>-->
                        <!--                            </li>-->
                        <li>
                            <p>访客类别：</p>
                            <!--                            <input type="text" name="category"/>-->
                            <select name="category" th:with="type=${@dict.getType('fw_visitor_category')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.getDictLabel()}"
                                        th:value="${dict.getDictValue()}"></option>
                            </select>
                        </li>
                        <!--                            <li>-->
                        <!--                                <p>授权访问次数：</p>-->
                        <!--                                <input type="text" name="authorizedDuration"/>-->
                        <!--                            </li>-->
                        <!--                            <li>-->
                        <!--                                <p>创建人：</p>-->
                        <!--                                <input type="text" name="creator"/>-->
                        <!--                            </li>-->
                        <!--                            <li>-->
                        <!--                                <p>修改人：</p>-->
                        <!--                                <input type="text" name="modifier"/>-->
                        <!--                            </li>-->
                        <li class="select-time">
                            <p>登记时间：</p>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginModifyTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endModifyTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="personnel:userInfo:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="personnel:userInfo:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="personnel:userInfo:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="personnel:userInfo:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('personnel:userInfo:edit')}]];
    var removeFlag = [[${@permission.hasPermi('personnel:userInfo:remove')}]];
    var showFlag = [[${@permission.hasPermi('wx:access:examine')}]];
    var prefix = ctx + "personnel/userInfo"

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            height: 575,
            modalName: "访客信息",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                // {
                //     field : 'openId',
                //     title : '微信返回用户的唯一标识'
                // },
                {
                    field: 'name',
                    title: '姓名',
                    align: 'center',
                    halign: 'center'
                },
                {
                    field: 'gender',
                    title: '性别',
                    align: 'center',
                    halign: 'center',
                    formatter : function (value, row, index) {
                        if(value == 0){
                            return "男";
                        }else if(value == 1){
                            return "女";
                        }else {
                            return "未知";
                        }
                    }
                },
                {
                    field: 'idNumber',
                    title: '身份证号码',
                    align: 'center',
                    halign: 'center'
                },
                {
                    field: 'phone',
                    title: '手机号码',
                    align: 'center',
                    halign: 'center'
                },
                {
                    field: 'presentAddress',
                    title: '现住址',
                    align: 'center',
                    halign: 'center'
                },
                // {
                //     field : 'province',
                //     title : '省'
                // },
                // {
                //     field : 'city',
                //     title : '市'
                // },
                // {
                //     field : 'district',
                //     title : '区/县'
                // },
                {
                    field: 'category',
                    title: '访客类别',
                    align: 'center',
                    halign: 'center',
                    formatter:function (value, row, index) {
                        if(value == 0){
                            return "常住";
                        }else if(value == 1){
                            return "非常住";
                        }
                    }
                },
                // {
                //     field: 'authorizedDuration',
                //     title: '授权访问次数',
                //     sortable: true
                // },
                // {
                //     field : 'creator',
                //     title : '创建人'
                // },
                // {
                //     field : 'modifier',
                //     title : '修改人'
                // },
                {
                    field: 'modifyTime',
                    title: '登记时间',
                    align: 'center',
                    halign: 'center'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>&nbsp;');
                        actions.push('<a class="btn btn-info btn-xs ' + showFlag + '" href="javascript:void(0)" onclick="showRecord(\'' + row.openId + '\')"><i class="fa fa-eye"></i>查看</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function showRecord(openId) {
        var url = ctx + "wx/access/examine/" + openId;
        $.modal.open("查看访客记录", url);
    }


</script>
</body>
</html>